-- optimization
-- created by xinj
-- 攻击时获得优化点

return {
    apply = function(prop, baseValue)
        return baseValue + prop[3];
    end,

    -- 进入下一层触发
    trigger = function(who, prop, arg)
        local opti = who.dbase:query("opti_point", 0);

        -- 加成
        local value = prop[3];
        local specialProp = PropM.combine(who, "prop_force_add", prop[1]);
        if specialProp[3] > 0 then
            value = PropM.apply(specialProp, value);
        end

        opti = opti + value;

        who.dbase:set("opti_point", opti);

        local target = arg;
        local pos = target:getPos();
        EventMgr.fire(event.SOUL_COLLECT, {["amount"] = value, ["pos"] = pos, ["attrib"] = "opti_point" });
        return true;
    end,

    record = function(target, prop, path)
        return false;
    end
};